-
Couldn't load subscription status.
- Fork 78
feat(FR-1572): improve keyboard interaction and focus management for editable name components #4421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(FR-1572): improve keyboard interaction and focus management for editable name components #4421
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 51.38% | 130/253 |
| 🔴 | Branches | 30.3% | 80/264 |
| 🔴 | Functions | 34.48% | 20/58 |
| 🔴 | Lines | 53.85% | 119/221 |
Test suite run success
55 tests passing in 3 suites.
Report generated by 🧪jest coverage report action from f4e515a
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 4.65% | 532/11446 |
| 🔴 | Branches | 3.76% | 302/8030 |
| 🔴 | Functions | 2.87% | 102/3548 |
| 🔴 | Lines | 4.6% | 514/11186 |
Test suite run success
121 tests passing in 14 suites.
Report generated by 🧪jest coverage report action from f4e515a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves keyboard interaction and focus management for editable name components to prevent modals from closing when ESC is pressed during name editing.
- Adds focus management with useRef to return focus after editing completes
- Implements ESC key event propagation stopping during editing to prevent unintended modal closure
- Enables keyboard-based modal closing for FolderExplorer when not in editing mode
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| react/src/components/FolderExplorer.tsx | Enables keyboard prop to allow ESC key to close modal when not editing |
| react/src/components/EditableVFolderName.tsx | Adds focus management, ESC propagation stopping, and React compiler directive |
| react/src/components/ComputeSessionNodeItems/EditableSessionName.tsx | Adds focus management, ESC propagation stopping, and React compiler directive |
| packages/backend.ai-ui/src/components/baiClient/FileExplorer/EditableFileName.tsx | Adds focus management, ESC propagation stopping, and React compiler directive |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good as it is now, but couldn’t we create a hook to reduce duplicate code?
import { useRef, useCallback } from 'react';
export function useEditableFocusManagement<T extends HTMLElement = HTMLElement>() {
const textRef = useRef<T>(null);
const focusFallback = useCallback(() => {
setTimeout(() => {
textRef.current?.focus();
}, 0);
}, []);
const createEscapeHandler = useCallback((
onEscape: () => void
) => {
return (e: React.KeyboardEvent) => {
if (e.key === 'Escape') {
e.stopPropagation();
onEscape();
}
};
}, []);
return {
textRef,
focusFallback,
createEscapeHandler,
textProps: {
ref: textRef,
tabIndex: -1 as const,
style: { outline: 'none' } as const,
},
};
}
const { focusFallback, createEscapeHandler, textProps } =
useEditableFocusManagement<HTMLSpanElement>();
<Component {...textProps} />
<Input
onKeyDown={createEscapeHandler(() => {
setIsEditing(false);
focusFallback();
})}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. Also, please resolve the conflicts :)
a07c6df to
8d91a94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merge activity
|
…editable name components (#4421) Resolves #4420 ([FR-1572](https://lablup.atlassian.net/browse/FR-1572)) ## Summary This PR improves keyboard interaction and focus management for editable name components in the session detail drawer and folder explorer modal. ## Changes - Added focus management using useRef and focus fallback functions to EditableFileName, EditableSessionName, and EditableVFolderName components - Implemented event.stopPropagation() for ESC key during editing to prevent modal closing - Added proper tabIndex and focus handling after editing completes - Enabled keyboard modal closing (keyboard prop) for FolderExplorer modal - Added 'use memo' directive for React compiler optimization ## Technical Details - When editing name fields, ESC key now cancels editing without closing the parent modal/drawer - After editing completes (either by confirmation or cancellation), focus returns to the text element with proper tabIndex - This ensures ESC key can properly close modals when not in editing mode - All editable name components now have consistent keyboard interaction behavior ## Testing - Test editing names in session detail drawer - ESC should cancel editing without closing drawer - Test editing names in folder explorer modal - ESC should cancel editing without closing modal - After editing, ESC should properly close the modal/drawer - Verify focus management works correctly when switching between editing and view modes [FR-1572]: https://lablup.atlassian.net/browse/FR-1572?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
dac6de8 to
f4e515a
Compare

Resolves #4420 (FR-1572)
Summary
This PR improves keyboard interaction and focus management for editable name components in the session detail drawer and folder explorer modal.
Changes
Technical Details
Testing